#! /bin/sh -vx
# $Id$
# Copyright 2017-2018 Karl Berry <tex-live@tug.org>
# Copyright 2014 Peter Breitenlohner <tex-live@tug.org>
# You may freely use, modify and/or distribute this file.

BinDir=${BinDir:-.}
ExeExt=${ExeExt:-}
_pmpost=$BinDir/pmpost$ExeExt
_eptex=$BinDir/eptex$ExeExt

LC_ALL=C; export LC_ALL;  LANGUAGE=C; export LANGUAGE

tests=pmpostdir/tests

test -d $tests || mkdir -p $tests

TEXMFCNF=${TEXMFCNF:-$srcdir/../kpathsea}
export TEXMFCNF

tfmpath=`$KPSEWHICH cmr10.tfm` || exit 77
TFMFONTS="$srcdir/$tests;`echo $tfmpath | sed 's,/fonts/tfm/.*$,/fonts/tfm//,'`"

mppath=`$KPSEWHICH plain.mp` || exit 77
MPINPUTS=".;`dirname $mppath`"

mappath=`$KPSEWHICH psfonts.map` || exit 77
TEXFONTMAPS=`echo $mappath | sed 's,/fonts/map/.*$,/fonts/map//,'`

t1path=`$KPSEWHICH cmmi10.pfb` || exit 77
T1FONTS="$srcdir/$tests;`echo $t1path | sed 's,/fonts/type1/.*$,/fonts/type1//,'`"

vfpath=`$KPSEWHICH min10.vf` || exit 77
VFFONTS="$srcdir/$tests;`dirname $vfpath`"

export TFMFONTS MPINPUTS TEXFONTMAPS T1FONTS VFFONTS

# check that we have eptex at all.
$_eptex -version >/dev/null 2>&1 || exit 77

# ensure that eptex.fmt exists and can be read.
$_eptex \\end >/dev/null 2>&1 || exit 77

echo 'input plain;' >pmpsamp.mp
cat "$srcdir/$tests/psample.mp" >>pmpsamp.mp

$_pmpost -ini -kanji=utf8 -tex=$_eptex pmpsamp || exit 1

